﻿using Managistics.Warehouse.Configuration;
using Managistics.Warehouse.Controllers.Interfaces;
using Managistics.Warehouse.Views.Interfaces;
using Managistics.Warehouse.Factories;
using Managistics.Core.Services;
using System.Collections.Generic;
using Managistics.Model;

namespace Managistics.Warehouse.Controllers
{
    public class ViewEnterInputSheetController : IViewEnterInputSheetController
    {
        private readonly IViewEnterInputSheetView fromViewEnterInputView;
        private readonly IEnterInputSheetService enterInputSheetService;

        public ViewEnterInputSheetController(IViewEnterInputSheetView fromViewEnterInputView,
            IEnterInputSheetService enterInputSheetService)
        {
            this.fromViewEnterInputView = fromViewEnterInputView;
            this.enterInputSheetService = enterInputSheetService;

            fromViewEnterInputView.SaveInputSheet += SaveInputSheet;
        }

        public void Run()
        {
            fromViewEnterInputView.Open();
        }

        public void Stop(string key) { }

        private void SaveInputSheet()
        {
            ViewEnterInputSheetParam p = fromViewEnterInputView.GetParams();
            this.enterInputSheetService.saveInputSheet(p);
        }
    }
}